package com.itheima.day07.myList.test1;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;

public class Test {
    public static void main(String[] args) {
        Random r = new Random();
        List<Integer> list = new ArrayList<>();

        for (int i = 0; i < 5; i++) {
            list.add(Integer.valueOf(r.nextInt(10) + 1));
        }

        // 迭代器遍历集合
        Iterator it = list.iterator();
        while (it.hasNext()) {
            System.out.print(it.next() + " ");
        }
        System.out.println();

        // 增强for循环遍历集合
        for(Integer i : list){
            System.out.print(i.intValue() + " ");
        }

    }
}
